package com.drakulo.games.ais.ui.component.window;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;

import com.drakulo.games.ais.ui.UIHelper;
import com.drakulo.games.ais.ui.component.UIComponent;

/**
 * Renders a simple window background. To be used as a base for other
 * UIComponents
 * 
 * @author Drakulo
 * 
 */
public class Window extends UIComponent {

	/**
	 * Constructor
	 * 
	 * @param x
	 *            - the X coordinate of the top left point of the window
	 * @param y
	 *            - the y coordinate of the top left point of the window
	 * @param w
	 *            - the window's width
	 * @param h
	 *            - the window's height
	 */
	public Window(int x, int y, int w, int h) {
		setOX(x);
		setOY(y);
		setWidth(w);
		setHeight(h);
	}

	@Override
	public void render(Graphics g) throws SlickException {
		if (isShown()) {
			UIHelper.drawWindow(g, getOX(), getOY(), getWidth(), getHeight(), 5);
		}
	}

	@Override
	public void update(Input input) throws SlickException {
		// Update the hover flag
		super.updateHovered(input.getMouseX(), input.getMouseY());
	}
}